package com.demo.service.impl;

import com.demo.constant.MessageConstant;
import com.demo.dto.UserLoginDTO;
import com.demo.exception.AccountNotFoundException;
import com.demo.exception.PasswordTypeErrorException;
import com.demo.mapper.UserMapper;
import com.demo.pojo.Student;
import com.demo.pojo.User;
import com.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    //用户登录
    public User login(UserLoginDTO userLoginDTO) {
        String userid = userLoginDTO.getUserid();
        String password = userLoginDTO.getPassword();
        User user = userMapper.selectUseridPasswordType(userid,password);
       return user;
    }

    @Override
    public Student saveInfo(User user) {
        String fullname=user.getFullname();
        Student student=userMapper.getInfo(fullname);
        return student;
    }

    //用户信息显示
    public User getByUserid(String userid) {
        User user = userMapper.selectUserUserid(userid);
        return user;
    }

    //管理员信息修改
    public void update(UserLoginDTO userLoginDTO) {
        userMapper.update(userLoginDTO);
    }
}
